<%@ page language="java" import="java.util.*,com.tjyx.maintain.dto.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>管理员管理页面</title>
		<jsp:include page="../common/head.jsp"></jsp:include>
		<link rel="stylesheet" type="text/css" href="common/css/tjyxCRUD.css" />
		<script type="text/javascript" src="common/js/tjyxCRUD.js"></script>
		<script type="text/javascript">
		var tjyxTableTitle = "管理员信息维护"; //表格标题
		var loadDataURL = "maintain_userInfoAction_managerList.do"; //数据装载请求地址
		var deleteURI = "maintain_userInfoAction_deleteUserInfo.do?ids="; //删除请求地址
		var columnsFields = [
			{field:'ck',checkbox:true},
			{field:'id',title:'id',align:'center',width:120},
			{field:'userName',title:'用户名',align:'center',width:120},
			{field:'opt',title:'操作',width:200,align:'center', rowspan:1,
				formatter:function(value,rowData,rowIndex){	
					var viewURI = 'maintain_userInfoAction_viewManagerById.do?id=' + rowData.id; //查看窗口请求地址
					var updateURI = 'maintain_userInfoAction_updateManagerById.do?id=' + rowData.id; //更新窗口请求地址			
					return "<a title='查看详细信息' class='viewInfo' href='javascript:tjyxWindowView(\""+ viewURI + "\")'>【查看】</a> <a title='修改信息' class='updateInfo' href='javascript:tjyxWindowUpdate(\"" + updateURI + "\")'>【修改】</a>";	
				}
			}	
		]
		var addWidth = 540; //添加信息宽度
		var addHeight = 150; //添加信息高度
		var addTitle = "添加管理员信息"; //添加信息标题
	
		var viewWidth = 540; //查看信息宽度
		var viewHeight = 150; //查看信息高度
		var viewTitle = "查看管理员信息"; //查看信息标题
	
		var updateWidth = 540; //修改信息宽度
		var updateHeight = 190; //修改信息高度
		var updateTitle = "修改管理员信息"; //修改信息标题
		
		//提交表单，以后补充装载验证信息
		function loadAddFormValidate(){
			var addForm = $('#add_form');
			$.post(addForm.attr("action"),addForm.serialize(),
				function(data){
					if(data=="ok"){						
						$('#tjyx_add').window('close');  //关闭添加窗口
						$.messager.alert("添加成功",$("#userNameAdd").val() + "，信息添加成功！");  //提示添加信息成功
						clearFormData('#add_form'); //清空添加表单数据
						loadPageData(1); //重新装载第1页数据
					} else {
						$.messager.alert("添加失败：",data);
					}
				},"html");				
		}
		
		//提交表单，以后补充装载验证信息
		function loadUpdateFormValidate(){
			var updateForm = $('#update_form');
			$.post(updateForm.attr("action"),updateForm.serialize(),
				function(data){
					if(data=="ok"){						
						$('#tjyx_update').window('close');  //关闭添加窗口
						$.messager.alert("修改成功",$("#userNameUpdate").val() + "，信息修改成功！");  //提示添加信息成功
						clearFormData('#update_form'); //清空更新表单数据
						$("#tjyx_table").datagrid("reload");
					} else {
						$.messager.alert("修改失败：",data);
					}
				},"html");				
		}
		//初始化更新窗口
		function initUpdateWindow(jsonObject) {
			$("#idUpdate").val(jsonObject.id);
			$("#userNameUpdate").val(jsonObject.userName);
			$("#passwordUpdate").val(jsonObject.password);
		}
		
		//初始化查询窗口
		function initViewWindow(jsonObject) {
			$("#userNameView").text(jsonObject.userName);
			$("#passwordView").text(jsonObject.password);
		}
	</script>
	</head>
	<body>
		<table id="tjyx_table"></table>

		<!-- 添加记录 -->
		<div id="tjyx_add">
			<form id="add_form" action="maintain_userInfoAction_addManager.do"
				method="post">
				<table border="0" id="tjyx_edit_table" width="520">
					<tbody>
						<tr>
							<td class="leftTd">
								姓名：
							</td>
							<td>
								<input type="text" id="userNameAdd" name="userName" />
							</td>
							<td>
								<div id="tip" style="width:210px">有待补充验证信息</div>
							</td>
						</tr>
						<tr>
							<td class="leftTd">
								密码：
							</td>
							<td>
								<input type="password" id="password" name="password"
									value="123456" readonly="readonly" />
							</td>
							<td>
								<div id="tip" style="width:210px">有待补充验证信息</div>
							</td>
						</tr>
						<tr>
							<td colspan="3" style="text-align: center">
								<a class="easyui-linkbutton" iconCls="icon-ok"
									onclick="loadAddFormValidate();">添加</a>
								<a class="easyui-linkbutton" iconCls="icon-undo"
									onclick="document.getElementById('add_form').reset()">重置</a>
								<a class="easyui-linkbutton" iconCls="icon-cancel"
									onclick="$('#tjyx_add').window('close');">取消</a>
							</td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>


		<!-- 查看记录 -->
		<div id="tjyx_view">
			<table border="0" id="tjyx_view_table" width="520">
				<tbody>
					<tr>
						<td class="leftTd">
							姓名：
						</td>
						<td>
							<span id="userNameView"></span>
						</td>
					</tr>
					<tr>
						<td class="leftTd">
							密码：
						</td>
						<td>
							<span id="passwordView"></span>
						</td>
					</tr>
				</tbody>
			</table>
		</div>

		<!-- 更新记录 -->
		<div id="tjyx_update">
			<form id="update_form" action="maintain_userInfoAction_updateManager.do"
				method="post">
				<table border="0" id="tjyx_update_table" width="520">
					<tbody>
						<tr>
							<td class="leftTd">
								ID(隐藏):
							</td>
							<td>
								<input type="text" id="idUpdate" name="id"  />
							</td>
						</tr>
						<tr>
							<td class="leftTd">
								姓名：
							</td>
							<td>
								<input type="text" id="userNameUpdate" name="userName"  />
							</td>
							<td>
								<div id="tip" style="width:210px">有待补充验证信息</div>
							</td>
						</tr>
						<tr>
							<td class="leftTd">
								密码：
							</td>
							<td>
								<input type="text" id="passwordUpdate" name="password" />
							</td>
							<td>
								<div id="tip" style="width:210px">有待补充验证信息</div>
							</td>
						</tr>
						<tr>
							<td colspan="3" style="text-align: center">
								<a class="easyui-linkbutton" iconCls="icon-ok"
									onclick="loadUpdateFormValidate();">修改</a>
								<a class="easyui-linkbutton" iconCls="icon-undo"
									onclick="document.getElementById('update_form').reset()">重置</a>
								<a class="easyui-linkbutton" iconCls="icon-cancel"
									onclick="$('#tjyx_update').window('close');">取消</a>
							</td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>

	</body>
</html>
